*********************************************************
**ANALYZING AID-DATA AND AFROBAROMETER FOURTH ROUND DATA*
**Last Edit: September 12, 2022, by KB*************************
*********************************************************

* Note: The graphics in this file make use of the scheme_tufte.ado graphics scheme.
 * ssc install scheme_tufte


use "data/AfroR4_distancescapitalAidprojects.dta", clear

reg NGOHELP less5km closecapital veryinterested interestXclose closeX5 interestXless5 interestXcloseX5 education rural youth old i.COUNTRY, cluster(uniqueea)
*what is the effect on far, not interested
lincom _b[less5km]
*what is the effect on far, interested
lincom _b[less5km]+ _b[interestXless5]
*what is the effect on close, not interested
lincom _b[less5km] + _b[closeX5]
*what is the effect on close, interested
lincom _b[less5km] + _b[closeX5] + _b[interestXless5] + _b[interestXcloseX5]


reg NGOHELP less10km closecapital veryinterested interestXclose closeX10 interestXless10 interestXcloseX10 education rural youth old i.COUNTRY, cluster(uniqueea)
*what is the effect on far, not interested
lincom _b[less10km]
*what is the effect on far, interested
lincom _b[less10km]+ _b[interestXless10]
*what is the effect on close, not interested
lincom _b[less10km] + _b[closeX10]
*what is the effect on close, interested
lincom _b[less10km] + _b[closeX10] + _b[interestXless10] + _b[interestXcloseX10]


reg NGOHELP less5km closecapital veryinterested interestXclose closeX5 interestXless5 interestXcloseX5 education rural youth old i.Q79 if Q79<900, cluster(uniqueea)
*what is the effect on far, not interested
lincom _b[less5km]
*what is the effect on far, interested
lincom _b[less5km]+ _b[interestXless5]
*what is the effect on close, not interested
lincom _b[less5km] + _b[closeX5]
*what is the effect on close, interested
lincom _b[less5km] + _b[closeX5] + _b[interestXless5] + _b[interestXcloseX5]


reg NGOHELP less10km closecapital veryinterested interestXclose closeX10 interestXless10 interestXcloseX10 education rural youth old i.Q79 if Q79<900, cluster(uniqueea)
*what is the effect on far, not interested
lincom _b[less10km]
*what is the effect on far, interested
lincom _b[less10km]+ _b[interestXless10]
*what is the effect on close, not interested
lincom _b[less10km] + _b[closeX10]
*what is the effect on close, interested
lincom _b[less10km] + _b[closeX10] + _b[interestXless10] + _b[interestXcloseX10]


*********************************************************
**FIGURE: GRAPHING MARGINAL EFFECTS OF AID BY CONDITION**
**For the purposes of graphing the effects of aid by combinations of citizen interest and state capacity
**simplest to translate the interactions between info and capacity into a 4-point categorical variable
*********************************************************

gen condition = 0 if closecapital==0 & veryinterested==0
replace condition = 1 if closecapital==0 & veryinterested==1
replace condition = 2 if closecapital==1 & veryinterested==0
replace condition = 3 if closecapital==1 & veryinterested==1

label define conditioncat 0 "Low State Capacity, Uninformed Citizen" 1 "Low State Capacity, Informed Citizen" 2 "High State Capacity, Uninformed Citizen" 3 "High State Capacity, Informed Citizen"
label values condition conditioncat

label var less5km "Aid Project (5)"
label var less10km "Aid Project (10)"
label define aidcat 0 "No Aid" 1 "ME for"
label values less5km aidcat
label values less10km aidcat


**********
*FIGURE 7*
**********

set scheme tufte
areg NGOHELP less5km#i.condition i.condition education rural youth old, absorb(COUNTRY) cluster(uniqueea)
estimates store A
coefplot A, xline(0) omitted baselevels drop(_cons education rural youth old 0.less5km#0.condition 0.less5km#1.condition 0.less5km#2.condition 0.less5km#3.condition 0.condition 1.condition 2.condition 3.condition)/*
*/ coeflabels(, interaction("" "")) xscale(range(-0.2 (0.2) 0.4)) title(Aid Project within 5 km)
graph export "figures_tables/Fig7_LeftPanel_aid5kmCOUNTRY_bytreatment.tif", replace

areg NGOHELP less10km#i.condition i.condition education rural youth old, absorb(COUNTRY) cluster(uniqueea)
estimates store B
coefplot B, xline(0) omitted baselevels drop(_cons education rural youth old 0.less10km#0.condition 0.less10km#1.condition 0.less10km#2.condition 0.less10km#3.condition 0.condition 1.condition 2.condition 3.condition)/*
*/ coeflabels(, interaction("" "")) xscale(range(-0.2 (0.2) 0.4)) title(Aid Project within 10 km)
graph export "figures_tables/Fig7_RightPanel_aid10kmCOUNTRY_bytreatment.tif", replace

